<?php
/**
 *
 * Projet Authentic CMS
 * @file 	   error.php
 *
 * PHP version 5
 *
 * @author     Mohammed Amine Kaabachi <jedevbien@gmail.com>
 * @author     Poly Charly <CharlyPoly@gmail.fr>
 * @copyright  2009 Authentic Development Group
 * @license    GNU General Public License v3
 * @since      File available since Version 0.1.0

 **/

class error
{

    static $_Instance;

    public static  function getInstance($type, $level, $message, $file, $line)
    {
        if (!isset(self::$_Instance))
        {
            self::$_Instance == new error($type, $level, $message, $file, $line);
        }
        self::set($type, $level, $message, $file, $line);
        return self::$_Instance;
    }

    public static function set($type, $level, $message, $file, $line)
    {
        //if ($level > E_WARNING)
//        {
//            $_Log = System::load('logs');
//            $tab = array(
//						  'FILE' => $file,
//						  'LINE' => $line,
//						  'MESSAGE' =>  $message,
//						  'DATE' => date("H:i:s"),
//						  'HEURE' => date("j, n, Y"),
//            		);
//
//            Logs::log('error',      $tab);
//            Logs::set('FILE',       $file);
//            Logs::set('LINE',       $line);
//            Logs::set('MESSAGE',    $message);
//            Logs::set('DATE',       date("H:i:s"));
//            Logs::set('HEURE',      date("j, n, Y"));
//            Logs::record();
// 
//        }

        // Error Template Display
        die("$type : ".$message.'-'.$file.'-'.$line.'-');
        
    }
	
	public static function handler ($level, $message, $file, $line) {
		die("$level : ".$message.'-'.$file.'-'.$line.'-');
	}
	
	public static function init() {
		set_error_handler(array('error', 'handler'));
		error_reporting(E_ALL | E_STRICT);
	}
}